
Ext.onReady(function(){
    var myFlightData;
    if (tripType == "single"){
        myFlightData = [[airNo, fromto_desc, position ,price, fly_date, fly_time, arr_time, plane_type]];
    }else{
        myFlightData = [[airNo, fromto_desc, position, price, fly_date, fly_time, arr_time, plane_type], [airNo2, fromto_desc2,position2, price2, fly_date2, fly_time2, arr_time2, plane_type2]];
    }
    var myFlightStore = new Ext.data.SimpleStore({
        fields: [{
            name: 'airno'
        }, {
            name: 'fromto'
        }, {
            name: 'position'
        }, {
            name: 'price'
        }, {
            name: 'fly_date'
        }, {
            name: 'fly_time'
        }, {
            name: 'arr_time'
        }, {
            name: 'plane_type'
        }]
    });
    myFlightStore.loadData(myFlightData);
    var myFlightGrid = new Ext.grid.GridPanel({
        el: 'flight_list_grid',
        height: 95,
        store: myFlightStore,
        title: '已选择的航班',
        columns: [new Ext.grid.RowNumberer(),{
            header: "航班号",
            width: 60,
            dataIndex: 'airno'
        }, {
            header: "航程",
            width: 150,
            dataIndex: 'fromto'
        }, {
            header: "舱位",
            width: 50,
            dataIndex: 'position'
        }, {
            header: "价格",
            width: 60,
            dataIndex: 'price'
        }, {
            header: "日期",
            width: 80,
            dataIndex: 'fly_date'
        }, {
            header: "起飞时间",
            width: 60,
            dataIndex: 'fly_time'
        }, {
            header: "降落时间",
            width: 60,
            dataIndex: 'arr_time'
        }, {
            header: "机型",
            width: 40,
            dataIndex: 'plane_type'
        }]//,
    //stripeRows: true,
    //autoExpandColumn: 'air'
    });
    myFlightGrid.render();
    //-------------------------------------------------------------
    var currentSeatNumber = 1;
    
    var linkMan = new Ext.form.TextField({
        fieldLabel: '联系人',
        name: 'link_man',
        allowBlank: false,
        blankText: '联系人必须填写',
        anchor: '90%'
    });
    var linkPhone = new Ext.form.TextField({
        fieldLabel: '联系电话',
        name: 'link_tel',
        allowBlank: false,
        blankText: '联系电话必须填写',
        anchor: '90%'
    });
    // level combobox
    var seatArray = [['1', '1'], ['2', '2'], ['3', '3'], ['4', '4'], ['5', '5'], ['6', '6'], ['7', '7'], ['8', '8'], ['9', '9']];
    var seatReader = new Ext.data.ArrayReader({
        id: 0
    }, [{
        name: 'value'
    }, {
        name: 'key'
    }]);
    var seatStore = new Ext.data.Store({
        reader: seatReader
    });
    seatStore.loadData(seatArray);
    var seatNumber = new Ext.form.ComboBox({ //combobox
        name: 'seat_number',
        fieldLabel: '座位数',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: person_number,
        store: seatStore //数据储存到这个comboBox
    });
    
    function seatSelect(){
        var selectedSeatNumber = parseInt(seatNumber.getValue());
        //Ext.MessageBox.alert('提示', selectedSeatNumber);
        //Ext.MessageBox.alert('提示', 'div_passenger_'+currentSeatNumber);
        ageType2.render();
        if (selectedSeatNumber == 1) {
            hideSeat();
        }
        else if (selectedSeatNumber > currentSeatNumber) {
            for (i = currentSeatNumber + 1; i <= selectedSeatNumber; i++) {
                //Ext.MessageBox.alert('提示', i);
                Ext.getCmp('div_passenger_' + i).show();
                eval('passengerName' + i + '.allowBlank=false');
                if (eval('ageType' + i).getValue() != "成人") {
                    eval('birthday' + i + '.allowBlank=false');
                }
            }
        }
        else {
            for (i = selectedSeatNumber + 1; i <= currentSeatNumber; i++) {
                //Ext.MessageBox.alert('提示', i);
                Ext.getCmp('div_passenger_' + i).hide();
                eval('birthday' + i + '.allowBlank=true');
                eval('passengerName' + i + '.allowBlank=true');
            }
        }
        currentSeatNumber = selectedSeatNumber;
    }
    seatNumber.on('select', seatSelect);
    
    //常旅客关键字搜索
    var pass_resultTpl = new Ext.XTemplate('<tpl for="."><div class="search-item">', '<h3>{name} {card}</h3>', '</div></tpl>');
    var pass_nameStore = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: "/customers/getPassengerComboBox"
        }),
        reader: new Ext.data.JsonReader({
            root: 'root'
        }, [{
            name: 'name'
        }, {
            name: 'phone'
        }, {
            name: 'card'
        }])
    });
    var passengerName1 = new Ext.form.ComboBox({
        store: pass_nameStore,
        fieldLabel: '乘客姓名',
        name: 'pessenger_name_1',
        allowBlank: false,
        blankText: "乘客姓名不允许为空",
        //displayField: 'name',
        typeAhead: false,
        loadingText: 'Searching...',
        //width: 230,
        anchor: '90%',
        //hideTrigger: true,
        tpl: pass_resultTpl,
        minChars: 0,
        itemSelector: 'div.search-item',
        onSelect: function(record){
            passengerName1.setValue(record.data.name);
            card1.setValue(record.data.card);
            if (this.isExpanded()) {
                this.collapse();
            }
        }
    });
    var card1 = new Ext.form.TextField({
        fieldLabel: '证件号码',
        name: 'card_1',
        anchor: '90%'
    });
    var birthday1 = new Ext.form.DateField({
        fieldLabel: '生日',
        name: 'birthday_1',
        format: 'Y-m-d', //格式化日期
        //disabledDays: [0,6],	//不让选择周六，周日
        //disabledDaysText: "周末要休息",
        invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
        allowBlank: true,
        blankText: "出生日期必须选择",
        //emptyText: '请选择...',
        inputType: '2008-01-01',
        //anchor: '50%'
        width: 90
    });
    var ageTypeArray = [['成人', '成人'], ['儿童', '儿童']];
    var ageTypeReader = new Ext.data.ArrayReader({
        id: 0
    }, [{
        name: 'key'
    }, {
        name: 'value'
    }]);
    var ageTypeStore = new Ext.data.Store({
        reader: ageTypeReader
    });
    ageTypeStore.loadData(ageTypeArray);
    var ageType1 = new Ext.form.ComboBox({ //combobox
        name: 'age_type_1',
        fieldLabel: '类型',
        resiable: true,
        typeAhead: true,
        handleHeight: 100,
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: "成人",
        store: ageTypeStore,
        listeners: {
            select: function(combo, record, index){
                if (record.data.value == "成人") {
                    birthday1.allowBlank = true;
                    card1.enable();
                }
                else {
                    birthday1.allowBlank = false;
                    card1.setValue('');
                    card1.disable();
                }
            }
        }
    });
    var insuranceArray = [['0', '0'], ['1', '1'], ['2', '2']];
    var insuranceReader = new Ext.data.ArrayReader({
        id: 0
    }, [{
        name: 'value'
    }, {
        name: 'key'
    }]);
    var insuranceStore = new Ext.data.Store({
        reader: insuranceReader
    });
    insuranceStore.loadData(insuranceArray);
    var insurance1 = new Ext.form.ComboBox({ //combobox
        name: 'insurance_1',
        fieldLabel: '保险',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: 0,
        store: insuranceStore
    });
    //2
    var passengerName2 = new Ext.form.ComboBox({
        store: pass_nameStore,
        fieldLabel: '乘客姓名',
        name: 'pessenger_name_2',
        allowBlank: true,
        blankText: "乘客姓名不允许为空",
        //displayField: 'name',
        typeAhead: false,
        loadingText: 'Searching...',
        //width: 230,
        anchor: '90%',
        //hideTrigger: true,
        tpl: pass_resultTpl,
        minChars: 0,
        itemSelector: 'div.search-item',
        onSelect: function(record){
            passengerName2.setValue(record.data.name);
            card2.setValue(record.data.card);
            if (this.isExpanded()) {
                this.collapse();
            }
        }
    });
    var card2 = new Ext.form.TextField({
        fieldLabel: '证件号码',
        name: 'card_2',
        anchor: '90%'
    });
    var birthday2 = new Ext.form.DateField({
        fieldLabel: '生日',
        name: 'birthday_2',
        format: 'Y-m-d', //格式化日期
        //disabledDays: [0,6],	//不让选择周六，周日
        //disabledDaysText: "周末要休息",
        invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
        allowBlank: true,
        blankText: "出生日期必须选择",
        //emptyText: '请选择...',
        inputType: '2008-01-01',
        //anchor: '50%'
        width: 90
    });
    var ageType2 = new Ext.form.ComboBox({ //combobox
        name: 'age_type_2',
        fieldLabel: '类型',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: "成人",
        store: ageTypeStore,
        listeners: {
            select: function(combo, record, index){
                if (record.data.value == "成人") {
                    birthday2.allowBlank = true;
                    card2.enable();
                }
                else {
                    birthday2.allowBlank = false;
                    card2.setValue('');
                    card2.disable();
                }
            }
        }
    });
    var insurance2 = new Ext.form.ComboBox({ //combobox
        name: 'insurance_2',
        fieldLabel: '保险',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: 0,
        store: insuranceStore
    });
    //3
    var passengerName3 = new Ext.form.ComboBox({
        store: pass_nameStore,
        fieldLabel: '乘客姓名',
        name: 'pessenger_name_3',
        allowBlank: true,
        blankText: "乘客姓名不允许为空",
        //displayField: 'name',
        typeAhead: false,
        loadingText: 'Searching...',
        //width: 230,
        anchor: '90%',
        //hideTrigger: true,
        tpl: pass_resultTpl,
        minChars: 0,
        itemSelector: 'div.search-item',
        onSelect: function(record){
            passengerName3.setValue(record.data.name);
            card3.setValue(record.data.card);
            if (this.isExpanded()) {
                this.collapse();
            }
        }
    });
    var card3 = new Ext.form.TextField({
        fieldLabel: '证件号码',
        name: 'card_3',
        anchor: '90%'
    });
    var birthday3 = new Ext.form.DateField({
        fieldLabel: '生日',
        name: 'birthday_3',
        format: 'Y-m-d', //格式化日期
        //disabledDays: [0,6],	//不让选择周六，周日
        //disabledDaysText: "周末要休息",
        invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
        allowBlank: true,
        blankText: "出生日期必须选择",
        //emptyText: '请选择...',
        inputType: '2008-01-01',
        //anchor: '50%'
        width: 90
    });
    var ageType3 = new Ext.form.ComboBox({ //combobox
        name: 'age_type_3',
        fieldLabel: '类型',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: "成人",
        store: ageTypeStore,
        listeners: {
            select: function(combo, record, index){
                if (record.data.value == "成人") {
                    birthday3.allowBlank = true;
                    card3.enable();
                }
                else {
                    birthday3.allowBlank = false;
                    card3.setValue('');
                    card3.disable();
                }
            }
        }
    });
    var insurance3 = new Ext.form.ComboBox({ //combobox
        name: 'insurance_3',
        fieldLabel: '保险',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: 0,
        store: insuranceStore
    });
    //4
    var passengerName4 = new Ext.form.ComboBox({
        store: pass_nameStore,
        fieldLabel: '乘客姓名',
        name: 'pessenger_name_4',
        allowBlank: true,
        blankText: "乘客姓名不允许为空",
        //displayField: 'name',
        typeAhead: false,
        loadingText: 'Searching...',
        //width: 230,
        anchor: '90%',
        //hideTrigger: true,
        tpl: pass_resultTpl,
        minChars: 0,
        itemSelector: 'div.search-item',
        onSelect: function(record){
            passengerName4.setValue(record.data.name);
            card4.setValue(record.data.card);
            if (this.isExpanded()) {
                this.collapse();
            }
        }
    });
    var card4 = new Ext.form.TextField({
        fieldLabel: '证件号码',
        name: 'card_4',
        anchor: '90%'
    });
    var birthday4 = new Ext.form.DateField({
        fieldLabel: '生日',
        name: 'birthday_4',
        format: 'Y-m-d', //格式化日期
        //disabledDays: [0,6],	//不让选择周六，周日
        //disabledDaysText: "周末要休息",
        invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
        allowBlank: true,
        blankText: "出生日期必须选择",
        //emptyText: '请选择...',
        inputType: '2008-01-01',
        //anchor: '50%'
        width: 90
    });
    var ageType4 = new Ext.form.ComboBox({ //combobox
        name: 'age_type_4',
        fieldLabel: '类型',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: "成人",
        store: ageTypeStore,
        listeners: {
            select: function(combo, record, index){
                if (record.data.value == "成人") {
                    birthday4.allowBlank = true;
                    card4.enable();
                }
                else {
                    birthday4.allowBlank = false;
                    card4.setValue('');
                    card4.disable();
                }
            }
        }
    });
    var insurance4 = new Ext.form.ComboBox({ //combobox
        name: 'insurance_4',
        fieldLabel: '保险',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: 0,
        store: insuranceStore
    });
    //5
    var passengerName5 = new Ext.form.ComboBox({
        store: pass_nameStore,
        fieldLabel: '乘客姓名',
        name: 'pessenger_name_5',
        allowBlank: true,
        blankText: "乘客姓名不允许为空",
        //displayField: 'name',
        typeAhead: false,
        loadingText: 'Searching...',
        //width: 230,
        anchor: '90%',
        //hideTrigger: true,
        tpl: pass_resultTpl,
        minChars: 0,
        itemSelector: 'div.search-item',
        onSelect: function(record){
            passengerName5.setValue(record.data.name);
            card5.setValue(record.data.card);
            if (this.isExpanded()) {
                this.collapse();
            }
        }
    });
    var card5 = new Ext.form.TextField({
        fieldLabel: '证件号码',
        name: 'card_5',
        anchor: '90%'
    });
    var birthday5 = new Ext.form.DateField({
        fieldLabel: '生日',
        name: 'birthday_5',
        format: 'Y-m-d', //格式化日期
        //disabledDays: [0,6],	//不让选择周六，周日
        //disabledDaysText: "周末要休息",
        invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
        allowBlank: true,
        blankText: "出生日期必须选择",
        //emptyText: '请选择...',
        inputType: '2008-01-01',
        //anchor: '50%'
        width: 90
    });
    var ageType5 = new Ext.form.ComboBox({ //combobox
        name: 'age_type_5',
        fieldLabel: '类型',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: "成人",
        store: ageTypeStore,
        listeners: {
            select: function(combo, record, index){
                if (record.data.value == "成人") {
                    birthday5.allowBlank = true;
                    card5.enable();
                }
                else {
                    birthday5.allowBlank = false;
                    card5.setValue('');
                    card5.disable();
                }
            }
        }
    });
    var insurance5 = new Ext.form.ComboBox({ //combobox
        name: 'insurance_5',
        fieldLabel: '保险',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: 0,
        store: insuranceStore
    });
    //6
    var passengerName6 = new Ext.form.ComboBox({
        store: pass_nameStore,
        fieldLabel: '乘客姓名',
        name: 'pessenger_name_6',
        allowBlank: true,
        blankText: "乘客姓名不允许为空",
        //displayField: 'name',
        typeAhead: false,
        loadingText: 'Searching...',
        //width: 230,
        anchor: '90%',
        //hideTrigger: true,
        tpl: pass_resultTpl,
        minChars: 0,
        itemSelector: 'div.search-item',
        onSelect: function(record){
            passengerName6.setValue(record.data.name);
            card6.setValue(record.data.card);
            if (this.isExpanded()) {
                this.collapse();
            }
        }
    });
    var card6 = new Ext.form.TextField({
        fieldLabel: '证件号码',
        name: 'card_6',
        anchor: '90%'
    });
    var birthday6 = new Ext.form.DateField({
        fieldLabel: '生日',
        name: 'birthday_6',
        format: 'Y-m-d', //格式化日期
        //disabledDays: [0,6],	//不让选择周六，周日
        //disabledDaysText: "周末要休息",
        invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
        allowBlank: true,
        blankText: "出生日期必须选择",
        //emptyText: '请选择...',
        inputType: '2008-01-01',
        //anchor: '50%'
        width: 90
    });
    var ageType6 = new Ext.form.ComboBox({ //combobox
        name: 'age_type_6',
        fieldLabel: '类型',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: "成人",
        store: ageTypeStore,
        listeners: {
            select: function(combo, record, index){
                if (record.data.value == "成人") {
                    birthday6.allowBlank = true;
                    card6.enable();
                }
                else {
                    birthday6.allowBlank = false;
                    card6.setValue('');
                    card6.disable();
                }
            }
        }
    });
    var insurance6 = new Ext.form.ComboBox({ //combobox
        name: 'insurance_6',
        fieldLabel: '保险',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: 0,
        store: insuranceStore
    });
    //7
    var passengerName7 = new Ext.form.ComboBox({
        store: pass_nameStore,
        fieldLabel: '乘客姓名',
        name: 'pessenger_name_7',
        allowBlank: true,
        blankText: "乘客姓名不允许为空",
        //displayField: 'name',
        typeAhead: false,
        loadingText: 'Searching...',
        //width: 230,
        anchor: '90%',
        //hideTrigger: true,
        tpl: pass_resultTpl,
        minChars: 0,
        itemSelector: 'div.search-item',
        onSelect: function(record){
            passengerName7.setValue(record.data.name);
            card7.setValue(record.data.card);
            if (this.isExpanded()) {
                this.collapse();
            }
        }
    });
    var card7 = new Ext.form.TextField({
        fieldLabel: '证件号码',
        name: 'card_7',
        anchor: '90%'
    });
    var birthday7 = new Ext.form.DateField({
        fieldLabel: '生日',
        name: 'birthday_7',
        format: 'Y-m-d', //格式化日期
        //disabledDays: [0,6],	//不让选择周六，周日
        //disabledDaysText: "周末要休息",
        invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
        allowBlank: true,
        blankText: "出生日期必须选择",
        //emptyText: '请选择...',
        inputType: '2008-01-01',
        //anchor: '50%'
        width: 90
    });
    var ageType7 = new Ext.form.ComboBox({ //combobox
        name: 'age_type_7',
        fieldLabel: '类型',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: "成人",
        store: ageTypeStore,
        listeners: {
            select: function(combo, record, index){
                if (record.data.value == "成人") {
                    birthday7.allowBlank = true;
                    card7.enable();
                }
                else {
                    birthday7.allowBlank = false;
                    card7.setValue('');
                    card7.disable();
                }
            }
        }
    });
    var insurance7 = new Ext.form.ComboBox({ //combobox
        name: 'insurance_7',
        fieldLabel: '保险',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: 0,
        store: insuranceStore
    });
    
    //8
    var passengerName8 = new Ext.form.ComboBox({
        store: pass_nameStore,
        fieldLabel: '乘客姓名',
        name: 'pessenger_name_8',
        allowBlank: true,
        blankText: "乘客姓名不允许为空",
        //displayField: 'name',
        typeAhead: false,
        loadingText: 'Searching...',
        //width: 230,
        anchor: '90%',
        //hideTrigger: true,
        tpl: pass_resultTpl,
        minChars: 0,
        itemSelector: 'div.search-item',
        onSelect: function(record){
            passengerName8.setValue(record.data.name);
            card8.setValue(record.data.card);
            if (this.isExpanded()) {
                this.collapse();
            }
        }
    });
    var card8 = new Ext.form.TextField({
        fieldLabel: '证件号码',
        name: 'card_8',
        anchor: '90%'
    });
    var birthday8 = new Ext.form.DateField({
        fieldLabel: '生日',
        name: 'birthday_8',
        format: 'Y-m-d', //格式化日期
        //disabledDays: [0,6],	//不让选择周六，周日
        //disabledDaysText: "周末要休息",
        invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
        allowBlank: true,
        blankText: "出生日期必须选择",
        //emptyText: '请选择...',
        inputType: '2008-01-01',
        //anchor: '50%'
        width: 90
    });
    var ageType8 = new Ext.form.ComboBox({ //combobox
        name: 'age_type_8',
        fieldLabel: '类型',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: "成人",
        store: ageTypeStore,
        listeners: {
            select: function(combo, record, index){
                if (record.data.value == "成人") {
                    birthday8.allowBlank = true;
                    card8.enable();
                }
                else {
                    birthday8.allowBlank = false;
                    card8.setValue('');
                    card8.disable();
                }
            }
        }
    });
    var insurance8 = new Ext.form.ComboBox({ //combobox
        name: 'insurance_8',
        fieldLabel: '保险',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: 0,
        store: insuranceStore
    });
    //9
    var passengerName9 = new Ext.form.ComboBox({
        store: pass_nameStore,
        fieldLabel: '乘客姓名',
        name: 'pessenger_name_9',
        allowBlank: true,
        blankText: "乘客姓名不允许为空",
        //displayField: 'name',
        typeAhead: false,
        loadingText: 'Searching...',
        //width: 230,
        anchor: '90%',
        //hideTrigger: true,
        tpl: pass_resultTpl,
        minChars: 0,
        itemSelector: 'div.search-item',
        onSelect: function(record){
            passengerName9.setValue(record.data.name);
            card9.setValue(record.data.card);
            if (this.isExpanded()) {
                this.collapse();
            }
        }
    });
    var card9 = new Ext.form.TextField({
        fieldLabel: '证件号码',
        name: 'card_9',
        anchor: '90%'
    });
    var birthday9 = new Ext.form.DateField({
        fieldLabel: '生日',
        name: 'birthday_9',
        format: 'Y-m-d', //格式化日期
        //disabledDays: [0,6],	//不让选择周六，周日
        //disabledDaysText: "周末要休息",
        invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
        allowBlank: true,
        blankText: "出生日期必须选择",
        //emptyText: '请选择...',
        inputType: '2008-01-01',
        //anchor: '50%'
        width: 90
    });
    var ageType9 = new Ext.form.ComboBox({
        name: 'age_type_9',
        fieldLabel: '类型',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: "成人",
        store: ageTypeStore,
        listeners: {
            select: function(combo, record, index){
                if (record.data.value == "成人") {
                    birthday9.allowBlank = true;
                    card9.enable();
                }
                else {
                    birthday9.allowBlank = false;
                    card9.setValue('');
                    card9.disable();
                }
            }
        }
    });
    var insurance9 = new Ext.form.ComboBox({ //combobox
        name: 'insurance_9',
        fieldLabel: '保险',
        resiable: true,
        typeAhead: true,
        handleHeight: 100, //
        displayField: 'key',
        valueField: 'value',
        selectOnFocus: true,
        mode: 'local',
        width: 60,
        triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
        readOnly: true,
        value: 0,
        store: insuranceStore
    });
    //送,接信息
    var sendTicketDate = new Ext.form.DateField({
        fieldLabel: '送票日期',
        name: 'send_date',
        altFormats: 'Y-m-d',
        format: 'Y-m-d', //格式化日期
        //disabledDays: [0,6],	//不让选择周六，周日
        //disabledDaysText: "周末要休息",
        invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
        allowBlank: true,
        //emptyText: '请选择...',
        inputType: '2008-01-01',
        editable: false,
        minValue: today,
        //anchor: '50%'
        width: 90
    });
    var sendTicketTime = new Ext.form.TimeField({
        fieldLabel: '送票时间',
        name: 'send_time',
        altFormats: 'H:i',
        format: 'H:i',
        increment: 30,
        minValue: SEND_START_TIME,
        maxValue: SEND_END_TIME,
        editable: false,
        //anchor: '50%'
        width: 90
    });
    var jjTime = new Ext.form.TimeField({
        fieldLabel: '接机时间',
        name: 'jj_time',
        altFormats: 'H:i',
        format: 'H:i',
        increment: 60,
        minValue: JJ_START_TIME,
        maxValue: JJ_END_TIME,
        editable: false,
        //anchor: '50%'
        width: 90
    });
    //送票地址关键字搜索
    var sendAddress = new Ext.form.TextField({
        fieldLabel: '送票地址',
        name: 'send_address',
        anchor: '90%'
    });
    
    var jjAddress = new Ext.form.TextField({
        fieldLabel: '接机地址',
        name: 'jj_address',
        anchor: '90%',
        value: DEFAULT_JJ_ADDRESS
    });
    var jjRequest = new Ext.form.TextField({
        fieldLabel: '接机要求',
        name: 'jj_request',
        anchor: '90%'
    });
    
    var submitButton = new Ext.Button({
        text: ' 提 交 ',
        handler: function(){
            if (bookingTicketsFormPanel.form.isValid()) {
                submitButton.setDisabled(true);
                bookingTicketsFormPanel.form.submit({
                    waitMsg: '正在提交中......',
                    success: function(form, action){
                        var info = "";
                        if (action && action.result) {
                            info = action.result.info;
                        }
                        else {
                            info = '订票失败,具体失败原因请查询日志文件';
                        }
                        if (info.indexOf("成功") >= 0) {
                            Ext.MessageBox.alert('操作成功', info + '');
                        }
                        else {
                            Ext.MessageBox.alert('操作信息', info);
                            submitButton.setDisabled(false);
                        }
                    },
                    failure: function(form, action){
                        Ext.MessageBox.alert('操作失败', "订票失败");
                        submitButton.setDisabled(false);
                    }
                });
            }
        }
    })
    var bookingTicketsFormPanel = new Ext.form.FormPanel({
        //baseCls: 'x-plain',
        labelWidth: 60,
        labelAlign: 'right',
        frame: true,
        width: '100%',
        url: '/ticket/savePersonWebOrder?'+paramStr,
        //params: paramStr,
        //defaultType: 'textfield',
        items: [{
            layout: 'column',
            border: false,
            items: [{
                columnWidth: .2,
                layout: 'form',
                border: false,
                items: [linkMan]
            }, {
                columnWidth: .2,
                layout: 'form',
                border: false,
                items: [linkPhone]
            }, {
                columnWidth: .2,
                layout: 'form',
                border: false,
                items: [seatNumber]
            }]
        }, {
            xtype: 'fieldset',
            title: '常旅客信息',
            collapsible: true,
            autoHeight: true,
            items: [{
                layout: 'column',
                border: false,
                id: 'div_passenger_1',
                items: [{
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [passengerName1]
                }, {
                    columnWidth: .25,
                    layout: 'form',
                    border: false,
                    items: [card1]
                }, {
                    columnWidth: .15,
                    layout: 'form',
                    border: false,
                    items: [ageType1]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [birthday1]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [insurance1]
                }]
            }, {
                layout: 'column',
                border: false,
                id: 'div_passenger_2',
                items: [{
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [passengerName2]
                }, {
                    columnWidth: .25,
                    layout: 'form',
                    border: false,
                    items: [card2]
                }, {
                    columnWidth: .15,
                    layout: 'form',
                    border: false,
                    items: [ageType2]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [birthday2]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [insurance2]
                }]
            }, {
                layout: 'column',
                border: false,
                id: 'div_passenger_3',
                items: [{
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [passengerName3]
                }, {
                    columnWidth: .25,
                    layout: 'form',
                    border: false,
                    items: [card3]
                }, {
                    columnWidth: .15,
                    layout: 'form',
                    border: false,
                    items: [ageType3]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [birthday3]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [insurance3]
                }]
            }, {
                layout: 'column',
                border: false,
                id: 'div_passenger_4',
                items: [{
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [passengerName4]
                }, {
                    columnWidth: .25,
                    layout: 'form',
                    border: false,
                    items: [card4]
                }, {
                    columnWidth: .15,
                    layout: 'form',
                    border: false,
                    items: [ageType4]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [birthday4]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [insurance4]
                }]
            }, {
                layout: 'column',
                border: false,
                id: 'div_passenger_5',
                items: [{
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [passengerName5]
                }, {
                    columnWidth: .25,
                    layout: 'form',
                    border: false,
                    items: [card5]
                }, {
                    columnWidth: .15,
                    layout: 'form',
                    border: false,
                    items: [ageType5]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [birthday5]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [insurance5]
                }]
            }, {
                layout: 'column',
                border: false,
                id: 'div_passenger_6',
                items: [{
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [passengerName6]
                }, {
                    columnWidth: .25,
                    layout: 'form',
                    border: false,
                    items: [card6]
                }, {
                    columnWidth: .15,
                    layout: 'form',
                    border: false,
                    items: [ageType6]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [birthday6]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [insurance6]
                }]
            }, {
                layout: 'column',
                border: false,
                id: 'div_passenger_7',
                items: [{
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [passengerName7]
                }, {
                    columnWidth: .25,
                    layout: 'form',
                    border: false,
                    items: [card7]
                }, {
                    columnWidth: .15,
                    layout: 'form',
                    border: false,
                    items: [ageType7]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [birthday7]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [insurance7]
                }]
            }, {
                layout: 'column',
                border: false,
                id: 'div_passenger_8',
                items: [{
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [passengerName8]
                }, {
                    columnWidth: .25,
                    layout: 'form',
                    border: false,
                    items: [card8]
                }, {
                    columnWidth: .15,
                    layout: 'form',
                    border: false,
                    items: [ageType8]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [birthday8]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [insurance8]
                }]
            }, {
                layout: 'column',
                border: false,
                id: 'div_passenger_9',
                items: [{
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [passengerName9]
                }, {
                    columnWidth: .25,
                    layout: 'form',
                    border: false,
                    items: [card9]
                }, {
                    columnWidth: .15,
                    layout: 'form',
                    border: false,
                    items: [ageType9]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [birthday9]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [insurance9]
                }]
            }]
        }, {
            xtype: 'fieldset',
            title: '送票与接机信息',
            collapsible: true,
            autoHeight: true,
            items: [{
                layout: 'column',
                border: false,
                items: [{
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [sendTicketDate]
                }, {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [sendTicketTime]
                }, {
                    columnWidth: .6,
                    layout: 'form',
                    border: false,
                    items: [sendAddress]
                }]
            }, {
                layout: 'column',
                border: false,
                items: [{
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [jjTime]
                }, {
                    columnWidth: .4,
                    layout: 'form',
                    border: false,
                    items: [jjAddress]
                }, {
                    columnWidth: .4,
                    layout: 'form',
                    border: false,
                    items: [jjRequest]
                }]
            }]
        }],
        buttons: [submitButton]
    });
    //隐藏座位
    function hideSeat(){
        var pNum = parseInt(person_number);
        for (i = pNum+1; i < 10; i++) {
            //Ext.MessageBox.alert('提示', 'div_passenger_'+i.toString());
            Ext.getCmp('div_passenger_' + i).hide();
        }
    }
    //hideSeat();
    bookingTicketsFormPanel.render('booking_tickets');
    hideSeat();
})
